import asyncio
import time


async def fun1():
    # time.sleep(2)
    await asyncio.sleep(2)


async def fun2():
    # time.sleep(2)
    await asyncio.sleep(3)


async def fun3():
    # time.sleep(2)
    await asyncio.sleep(1)


# tasks = [fun1(), fun2(), fun3()]
# a = time.time()
# asyncio.run(asyncio.wait(tasks))
# b = time.time()
# print(round(b - a, 3))

# 推荐写法
async def main():
    tasks = [asyncio.create_task(fun1()), asyncio.create_task(fun2()),asyncio.create_task(fun3())]
    await asyncio.wait(tasks)


a = time.time()
asyncio.run(main())
b = time.time()
print(round(b - a, 3))
